package com.xiashitech.agent.instrumentation.redis.constants;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum CommandNames {
    GET("GET"),
    SETEX("SETEX"),
    PSETEX("PSETEX");
    private String name;

    public String getName() {
        return name;
    }

    private CommandNames(String name) {
        this.name = name;
    }

    public static Boolean isSupportedCommand(String commandName) {
        if(commandName == null) {
            return false;
        }
        List<CommandNames> commandNamesList = Arrays.asList(GET,SETEX,PSETEX);
        return commandNamesList.stream().anyMatch(commandNames -> commandNames.getName().equals(commandName));
    }

    public static List<String> getALLCommandName() {
        return Arrays.stream(CommandNames.values()).map(commandName -> commandName.getName()).collect(Collectors.toList());
    }
}
